package com.sun.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.mapper.UsersMapper;
import com.sun.pojo.dto.UsersDto;
import com.sun.pojo.entity.Users;
import com.sun.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author SunRui
 * @description service 实现
 * @date 2024/10/17 8:43
 */
@Service
public class UsersServiceImpl implements UsersService {
    @Autowired
    UsersMapper usersMapper;
    @Override
    public PageInfo<Users> selectUsersBy(UsersDto usersDto,Integer pageNum) {
        PageHelper.startPage(pageNum,5);
        List<Users> list = usersMapper.selectUsersBy(usersDto);
        PageInfo<Users> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int addUsers(Users users) {
        return usersMapper.addUsers(users);
    }

    @Override
    public int updateUsers(Users users) {
        return usersMapper.updateUsers(users);
    }

    @Override
    public int deleteUsers(Integer id, Integer status) {
        return usersMapper.deleteUsers(id,status);
    }

    @Override
    public String selectImagePath(Integer id) {
        return usersMapper.selectImagePath(id);
    }
}
